package team.shuguoyiyou.authcode.authcode.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import team.shuguoyiyou.authcode.authcode.model.common.ResponseModel;
import team.shuguoyiyou.authcode.authcode.model.vo.Authcode;
import team.shuguoyiyou.authcode.authcode.model.vo.CaptchaVO;
import team.shuguoyiyou.authcode.authcode.service.CaptchaService;

/**
 * Created by ZengJian on 2021/2/3 0003 上午 9:22
 */
@RestController
@RequestMapping("/captcha")
public class CaptchaController {

    @Autowired
    private CaptchaService captchaService;

    @PostMapping("/get")
    public ResponseModel get(@RequestBody CaptchaVO captchaVO) {
        return captchaService.get(captchaVO);
    }

    @PostMapping("/check")
    public ResponseModel check(@RequestBody CaptchaVO captchaVO) {
        return captchaService.check(captchaVO);
    }

    @PostMapping("/verify")
    public ResponseModel verify(@RequestBody CaptchaVO captchaVO) {
        return captchaService.verification(captchaVO);
    }

    @PostMapping("/getAuthcode")
    public String getAuthcode(@RequestBody Authcode authcode) {
        CaptchaVO captchaVO = new CaptchaVO();
        captchaVO.setCaptchaVerification(authcode.getCaptchaVerification());
        System.out.println("getCaptchaVerification:" + authcode.getCaptchaVerification());
        System.out.println("captchaVo:" + captchaVO);
        ResponseModel response = captchaService.verification(captchaVO);
        return response.getRepCode();
    }
}
